﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Windows.Forms;
using Sumen.Business;
using DevExpress.XtraEditors;
using DevExpress.XtraReports.UI;
using DevExpress.XtraSplashScreen;
using Sumen.Business.Factory;
using Sumen.Business.Permission;
using Sumen.Business.Presenter.Actor;
using Sumen.Business.Presenter.Category;
using Sumen.Business.Presenter.Inventory;
using Sumen.GUI.Entities;
using Sumen.GUI.Report.Barcode;
using Sumen.Library.Classes.Common;
using Sumen.Library.Enum;
using Sumen.Library.Froms;
using Sumen.Model.Model;


namespace Sumen.GUI.Inventory
{
    public partial class Frm_Stock_Inward : XtraUserControlKira
    {
        private List<inventory_details> _inventoryDetailses;
        private bool isChange = false;
        private EnumFormCode _fromCode = EnumFormCode.FrmInward;

        #region Presenter

        private ProductDetailsPresenter _productDetailsPresenter;
        private PositionXPresenter _positionXPresenter;
        private ProviderPresenter _providerPresenter;
        private StockPresenter _stockPresenter;
        private InwardPresenter _inwardPresenter;
        private InventoryPresenter _inventoryPresenter;
        private InventoryPresenter invent;
        #endregion

        #region From

        public Frm_Stock_Inward()
        {
            InitializeComponent();
            buttonsArray1.capQuyen(new Permission(_fromCode.ToString(), ClsPublic.User.User_Username));
            _productDetailsPresenter = new ProductDetailsPresenter();
            _positionXPresenter = new PositionXPresenter();
            _inwardPresenter = new InwardPresenter();
            _providerPresenter = new ProviderPresenter();
            _stockPresenter = new StockPresenter();
            invent = new InventoryPresenter();
            _inventoryDetailses = new List<inventory_details>();

            txtDate.EditValue = DateTime.Now;
            var query = new BindingSource(_inventoryDetailses, "");
            gridControl1.DataSource = query;
            buttonsArray1.btnXoa.Text = "Đặt lại";
        }

        private void Frm_Stock_Inward_Load(object sender, EventArgs e)
        {
            LoadForm();
        }

        public override void LoadForm()
        {
            loadListProduct();
            loadProvider();
            loadStock();
            LoadCodeInward();
            loadPosition(loopUpStock.EditValue + string.Empty);

        }

        private void Frm_Stock_Inward_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (isChange)
            {
                if (!ClsMsgBox.XacNhanDongTab())
                {
                    e.Cancel = true;
                    return;
                } this.Dispose();
            }

        }

        #endregion


        #region Button event

        private void buttonsArray1_btnEventAdd_click(object sender, EventArgs e)
        {
            if (Validation())
            {
                stock_inward pInward = new stock_inward();
                pInward.Inw_ID = txtCodeInward.EditValue + string.Empty;
                pInward.Inw_RefDate = (DateTime?)txtDate.EditValue;
                pInward.Inw_RefType = (int)EnumRefType.Inward;
                pInward.Inw_Stock_id = (string)loopUpStock.EditValue;
                pInward.Inw_Provider_ID = (string)loopUpProvider.EditValue;
                pInward.Inw_Provider_Name = loopUpProvider.Properties.GetDisplayText(loopUpProvider.EditValue);
                pInward.Inw_Provider_Address = txtAddress.EditValue + string.Empty;
                pInward.Inw_Provider_Contact = txtPhone.EditValue + string.Empty;
                pInward.Inw_Payment = (sbyte?)(chkPayment.CheckState == CheckState.Checked ? 1 : 0);
                pInward.Inw_Reason = txtReason.EditValue + string.Empty;
                pInward.Inw_VAT = Convert.ToInt32(txtVat.EditValue);
                pInward.Inw_Ship_Price = (decimal)Convert.ToDouble(txtShip.EditValue);
                pInward.Inw_Description = txtDesc.EditValue + string.Empty;
                pInward.Inw_Amount = (decimal)Convert.ToDouble(colAmount.SummaryItem.SummaryValue);
                pInward.Inw_User_ID = ClsPublic.User.User_Username;

                EntityFactory.getInstance().BeginTransactionEntities();
                if (_inwardPresenter.Add(_inventoryDetailses, pInward) > 0)
                {
                    EntityFactory.getInstance().commit();
                    ClsMsgBox.ThongTin("Nhập kho thành công.");
                    gridView1.UpdateGroupSummary();
                    ResetForm();
                    
                    ClsPublic.WriteLog(_fromCode, EnumFormStatus.Add, pInward.Inw_ID, "");
                }
            }
        }

        private void buttonsArray1_btnEventReset_click(object sender, EventArgs e)
        {
            if (ClsMsgBox.XacNhan("Bạn có chắc nạp lại?"))
            {
                ResetForm();
            }
        }

        private void buttonsArray1_btnEventPrintBarcode_click(object sender, EventArgs e)
        {
            rptPrintBarcode obj = new rptPrintBarcode();

            obj.CreateDocument(true);
            // printControl1.SetDocumentMapVisibility(true);

            //in form

            dsPrintBarcode ds = ConvertListToDataSet();
            obj.DataSource = ds;
            if (ds.ProductDetails.Rows.Count > 0)
            {
                //obj.Print();
                obj.ShowRibbonDesigner();
            }
            else
            {
                ClsMsgBox.ThongTin("Vui lòng chọn sản phẩm để in.");
            }
        }

        public dsPrintBarcode ConvertListToDataSet()
        {
            dsPrintBarcode ds = new dsPrintBarcode();
            for (int i = 0; i < _inventoryDetailses.Count; i++)
            {
                if (_inventoryDetailses[i].Invd_Description == "1")
                {
                    for (int j = 0; j < _inventoryDetailses[i].Invd_Quantity; j++)
                    {
                        DataRow row = ds.ProductDetails.NewRow();
                        row["Prods_Id"] = _inventoryDetailses[i].Invd_PRODUCT_DETAILS_ID;
                        row["Prod_Name"] = _inventoryDetailses[i].Invd_Product_Name;
                        row["CompanyName"] = ClsPublic.COMPANY_NAME;
                        ds.ProductDetails.Rows.Add(row);
                    }
                }
            }
            return ds;
        }

        private void buttonsArray1_btnEventClose_click(object sender, EventArgs e)
        {
            this.Dispose();
        }

        #endregion

        #region Grid event

        private void searchProduct_EditValueChanged(object sender, EventArgs e)
        {
            SearchLookUpEdit edit = sender as SearchLookUpEdit;

            object value = edit.Properties.View.GetFocusedRowCellValue("Prod_Product_Name");
            //object value1 = edit.Properties.View.GetFocusedRowCellValue("Color_Name");
            //object value2 = edit.Properties.View.GetFocusedRowCellValue("Size_Name");

            decimal priceInward = Convert.ToDecimal(edit.Properties.View.GetFocusedRowCellValue(colSearchInwardPrice));
            decimal price1 = Convert.ToDecimal(edit.Properties.View.GetFocusedRowCellValue(colSearchPrice1));
            decimal price2 = Convert.ToDecimal(edit.Properties.View.GetFocusedRowCellValue(colSearchPrice2));
            decimal price3 = Convert.ToDecimal(edit.Properties.View.GetFocusedRowCellValue(colSearchPrice3));
            decimal amount = Convert.ToDecimal(edit.Properties.View.GetFocusedRowCellValue(colSearchAmount));
            decimal quantity = Convert.ToDecimal(edit.Properties.View.GetFocusedRowCellValue(colQuantityExist));
            string productCode = edit.Properties.View.GetFocusedRowCellValue(colSearchProductID).ToString();
            gridView1.SetFocusedRowCellValue(colProductName, value);
            //gridView1.SetFocusedRowCellValue(colPrintBarcode, productCode);

            gridView1.SetFocusedRowCellValue(colQuantity, "0");
            gridView1.SetFocusedRowCellValue(colPrice, quantity != 0 ? (amount / quantity) : priceInward);
            gridView1.SetFocusedRowCellValue(colAmount, "0");
            gridView1.SetFocusedRowCellValue(colPrice1, price1);
            gridView1.SetFocusedRowCellValue(colPrice2, price2);
            gridView1.SetFocusedRowCellValue(colPrice3, price3);
        }
        //private Frm_Product_Edit _frmProductEdit;
        private void searchProduct_AddNewValue(object sender, DevExpress.XtraEditors.Controls.AddNewValueEventArgs e)
        {
            SplashScreenManager.ShowForm(typeof(WaitForm1));
            List<product_details> list;

            Frm_Product_Edit _frmProductEdit = new Frm_Product_Edit();
            SplashScreenManager.CloseForm();
            _frmProductEdit.EnumFormStatus = EnumFormStatus.Add;
            _frmProductEdit.ShowDialog();
            list = _frmProductEdit.ListProductDetailsesAddNew;

            if (list != null && list.Count > 0)
            {
                loadListProduct();
                for (int i = 0; i < list.Count; i++)
                {

                    product_details productDetailsTemp = new product_details();
                    productDetailsTemp = _productDetailsPresenter.GetById(list[i].Prods_ID);
                    inventory_details tempInventoryDetails = new inventory_details();
                    tempInventoryDetails.Invd_PRODUCT_DETAILS_ID = productDetailsTemp.Prods_ID;
                    tempInventoryDetails.Invd_Product_Name = productDetailsTemp.product.Prod_Product_Name;
                    tempInventoryDetails.Invd_Price = productDetailsTemp.product.Prod_Inward_Price;
                    tempInventoryDetails.Invd_Retails_Price = productDetailsTemp.product.Prod_Retails_Price;
                    tempInventoryDetails.Invd_Agent_Price = productDetailsTemp.product.Prod_Agent_Price;
                    tempInventoryDetails.Invd_Sale_Price = productDetailsTemp.product.Prod_Sale_Price;
                    tempInventoryDetails.Invd_Quantity = 0;
                    _inventoryDetailses.Add(tempInventoryDetails);

                    gridView1.AddNewRow();

                    //int rowHandle = gridView1.FocusedRowHandle;
                    int rowHandle = gridView1.GetRowHandle(gridView1.DataRowCount);
                    if (gridView1.IsNewItemRow(rowHandle))
                    {
                        gridView1.SetRowCellValue(rowHandle, colProductDetailsID, productDetailsTemp.Prods_ID);
                        gridView1.SetRowCellValue(rowHandle, colProductName,
                            productDetailsTemp.product.Prod_Product_Name);
                        gridView1.SetRowCellValue(rowHandle, colPrice, productDetailsTemp.product.Prod_Inward_Price);
                        gridView1.SetRowCellValue(rowHandle, colPrice1, productDetailsTemp.product.Prod_Retails_Price);
                        gridView1.SetRowCellValue(rowHandle, colPrice2, productDetailsTemp.product.Prod_Agent_Price);
                        gridView1.SetRowCellValue(rowHandle, colPrice3, productDetailsTemp.product.Prod_Sale_Price);
                        gridView1.SetRowCellValue(rowHandle, colQuantity, 0);
                        // gridView1.SetRowCellValue(rowHandle, colPrintBarcode, productDetailsTemp.Prods_ID);
                    }
                }
                gridView1.DeleteRow(gridView1.FocusedRowHandle);
                gridView1.FocusedRowHandle = 1;
            }
            gridView1.BestFitColumns();

        }

        private void calPrice_ValueChanged(object sender, EventArgs e)
        {

            CalcEdit edit = sender as CalcEdit;
            if (gridView1.GetFocusedRowCellValue(colQuantity) == null)
            {
                gridView1.SetFocusedRowCellValue(colQuantity, "0");
            }
            if (edit.EditValue == null) edit.EditValue = "0";
            string sQuantity = gridView1.GetFocusedRowCellValue(colQuantity).ToString();
            string sPrice = edit.EditValue + string.Empty;
            double pri = double.Parse(sPrice == "" || sPrice == null ? "0" : sPrice);
            double quantity = double.Parse(sQuantity == "" || sQuantity == null ? "0" : sQuantity);
            gridView1.SetFocusedRowCellValue(colAmount, pri * quantity);
        }

        private void lookUpPosition_EditValueChanged(object sender, EventArgs e)
        {
            LookUpEdit edit = sender as LookUpEdit;
            //string tempQuantity = edit.EditValue
        }

        private void calQuantity_ValueChanged(object sender, EventArgs e)
        {
            CalcEdit edit = sender as CalcEdit;
            if (gridView1.GetFocusedRowCellValue(colPrice) == null)
            {
                gridView1.SetFocusedRowCellValue(colPrice, "0");
            }
            object o = gridView1.GetFocusedRowCellValue(colPrice);
            string sPrice = gridView1.GetFocusedRowCellValue(colPrice).ToString();
            string sQuantity = edit.EditValue + string.Empty;
            double pri = double.Parse(sPrice == "" || sPrice == null ? "0" : sPrice);
            double quantity = double.Parse(sQuantity == "" || sQuantity == null ? "0" : sQuantity);
            //set gia trị mặc định là 0
            if (edit.EditValue == null) edit.EditValue = "0";
            //nhân lên thành tiền
            gridView1.SetFocusedRowCellValue(colAmount, pri * quantity);
        }

        private void gridView1_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e)
        {
            int iRow;
            iRow = gridView1.FocusedRowHandle;

            string sProductDetails = gridView1.GetRowCellValue(iRow, colProductDetailsID) + string.Empty;
            string sPosition = gridView1.GetRowCellValue(iRow, colPosition) + string.Empty;
            string sQuantity = gridView1.GetRowCellValue(iRow, colQuantity) + string.Empty;
            string sPrice = gridView1.GetRowCellValue(iRow, colPrice) + string.Empty;
            string sPrice1 = gridView1.GetRowCellValue(iRow, colPrice1) + string.Empty;
            string sPrice2 = gridView1.GetRowCellValue(iRow, colPrice2) + string.Empty;
            string sPrice3 = gridView1.GetRowCellValue(iRow, colPrice3) + string.Empty;
            if (string.IsNullOrEmpty(sProductDetails))
            {
                gridView1.SetColumnError(colProductDetailsID, string.Format("Bạn chưa chọn sản phẩm! ESC để bỏ qua."));
                e.Valid = false;
            }
            //if (string.IsNullOrEmpty(sPosition) || sPosition == "0")
            //{
            //    gridView1.SetColumnError(colPosition, string.Format("Bạn chưa chọn vị trí lưu trong kho! ESC để bỏ qua."));
            //    e.Valid = false;
            //}
            if (string.IsNullOrEmpty(sPrice) || sPrice == "0")
            {
                gridView1.SetColumnError(colPrice, string.Format("Bạn chưa nhập giá sản phẩm! ESC để bỏ qua."));
                e.Valid = false;
            }
            if (string.IsNullOrEmpty(sPrice1) || sPrice1 == "0")
            {
                gridView1.SetColumnError(colPrice1, string.Format("Bạn chưa nhập giá sản phẩm! ESC để bỏ qua."));
                e.Valid = false;
            }
            if (string.IsNullOrEmpty(sPrice2) || sPrice2 == "0")
            {
                gridView1.SetColumnError(colPrice2, string.Format("Bạn chưa nhập giá sản phẩm! ESC để bỏ qua."));
                e.Valid = false;
            }
            if (string.IsNullOrEmpty(sPrice3) || sPrice3 == "0")
            {
                gridView1.SetColumnError(colPrice3, string.Format("Bạn chưa nhập giá sản phẩm! ESC để bỏ qua."));
                e.Valid = false;
            }
            if (string.IsNullOrEmpty(sQuantity) || sQuantity == "0")
            {
                gridView1.SetColumnError(colQuantity, string.Format("Bạn chưa nhập số lượng sản phẩm! ESC để bỏ qua."));
                e.Valid = false;
            }
            //kiểm tra có lớn số lượng chứa trong kho quui định không
            int quantity = Convert.ToInt32(sQuantity == "" ? "0" : sQuantity);
            string maPos = gridView1.GetFocusedRowCellValue(colPosition) + string.Empty;
            position_x_inventory tempX = _positionXPresenter.GetById(maPos);
            if (tempX != null && (tempX.Posx_Quantity_Max - tempX.Posx_Quantity) < quantity)
            {
                gridView1.SetColumnError(colQuantity, "Số lượng chứa trong không đủ");
                e.Valid = false;
            }
        }

        private void gridView1_InvalidRowException(object sender, DevExpress.XtraGrid.Views.Base.InvalidRowExceptionEventArgs e)
        {
            e.ExceptionMode = DevExpress.XtraEditors.Controls.ExceptionMode.NoAction;
        }

        private void gridView1_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            isChange = true;
        }

        private void gridControl1_KeyDown(object sender, KeyEventArgs e)
        {
            int row = gridView1.FocusedRowHandle;
            if ((e.KeyCode == Keys.Delete))
            {
                if (ClsMsgBox.XacNhanXoaThongTin())
                {
                    gridView1.DeleteRow(row);
                    isChange = true;
                }
            }
        }

        #endregion


        #region Control Event

        private void txtDate_EditValueChanged(object sender, EventArgs e)
        {
            LoadCodeInward();
        }

        private void loopUpProvider_EditValueChanged(object sender, EventArgs e)
        {
            string sProvider = loopUpProvider.EditValue + string.Empty;
            provider oProvider = _providerPresenter.GetById(sProvider);
            if (oProvider != null)
            {
                txtAddress.EditValue = oProvider.Prov_Contact;
                txtPhone.EditValue = oProvider.Prov_Tel;
            }
        }

        private void loopUpStock_EditValueChanged(object sender, EventArgs e)
        {
            loadPosition(loopUpStock.EditValue + string.Empty);
            LoadCodeInward();
        }

        #endregion


        #region Method

        private ICollection<product_details> listProductDetailses;
        void loadListProduct()
        {
            if (listProductDetailses != null) listProductDetailses.Clear();
            var list = _productDetailsPresenter.GetAllInventory();
            searchProduct.DataSource = null;
            searchProduct.DataSource = list.First();
            searchProduct.View.ExpandAllGroups();
            searchProduct.View.BestFitColumns();
        }

        void loadPosition(string pStockId)
        {
            var list = _positionXPresenter.GetByKey(pStockId);
            lookUpPosition.DataSource = null;
            lookUpPosition.DataSource = list.First();
        }

        void loadProvider()
        {
            loopUpProvider.Properties.DataSource = null;
            loopUpProvider.Properties.DataSource = _providerPresenter.GetAll();
        }

        void loadStock()
        {
            loopUpStock.Properties.DataSource = null;
            loopUpStock.Properties.DataSource = _stockPresenter.GetAll();
        }

        private void LoadCodeInward()
        {
            txtCodeInward.EditValue = _inwardPresenter.GetNewId(txtDate.EditValue, loopUpStock.EditValue + string.Empty) + string.Empty;
        }

        private void ResetForm()
        {
            isChange = false;
            loopUpProvider.EditValue = null;
            txtShip.EditValue = null;
            //loopUpStock.EditValue = null;
            txtReason.EditValue = null;
            txtAddress.EditValue = null;
            txtPhone.EditValue = null;
            txtVat.EditValue = 0;
            txtDesc.EditValue = null;
            gridControl1.DataSource = null;
            _inventoryDetailses.Clear();
            var query = new BindingSource(_inventoryDetailses, "");
            gridControl1.DataSource = query;
            LoadCodeInward();
            Refresh();
        }

        private bool Validation()
        {
            //kiem tra vi tri trong con trong' khong
            dxErrorProvider1.ClearErrors();
            if (loopUpProvider.EditValue == null || loopUpProvider.EditValue == "")
            {
                dxErrorProvider1.SetError(loopUpProvider, "Vui lòng nhập");
                return false;
            }
            //if (txtShip.EditValue == null || txtShip.EditValue == "")
            //{
            //    dxErrorProvider1.SetError(txtShip, "Vui lòng nhập");
            //    return false;
            //}
            if (loopUpStock.EditValue == null || loopUpStock.EditValue == "")
            {
                dxErrorProvider1.SetError(loopUpStock, "Vui lòng nhập");
                return false;
            }
            if (txtCodeInward.EditValue == null || txtCodeInward.EditValue == "")
            {
                dxErrorProvider1.SetError(txtCodeInward, "Vui lòng nhập");
                return false;
            }
            for (int i = 0; i < gridView1.DataRowCount; i++)
            {
                int iRow = i;

                string sProductDetails = gridView1.GetRowCellValue(iRow, colProductDetailsID) + string.Empty;
                //string sPosition = gridView1.GetRowCellValue(iRow, colPosition) + string.Empty;
                string sQuantity = gridView1.GetRowCellValue(iRow, colQuantity) + string.Empty;
                string sPrice = gridView1.GetRowCellValue(iRow, colPrice) + string.Empty;
                string sPrice1 = gridView1.GetRowCellValue(iRow, colPrice1) + string.Empty;
                string sPrice2 = gridView1.GetRowCellValue(iRow, colPrice2) + string.Empty;
                string sPrice3 = gridView1.GetRowCellValue(iRow, colPrice3) + string.Empty;
                if (string.IsNullOrEmpty(sProductDetails))
                {
                    gridView1.FocusedRowHandle = i;
                    gridView1.SetColumnError(colProductDetailsID, string.Format("Bạn chưa chọn sản phẩm! ESC để bỏ qua."));
                    return false;
                }
                //if (string.IsNullOrEmpty(sPosition) || sPosition == "0")
                //{
                //    gridView1.FocusedRowHandle = i;
                //    gridView1.SetColumnError(colPosition, string.Format("Bạn chưa chọn vị trí lưu trong kho! ESC để bỏ qua."));
                //    return false;
                //}
                if (string.IsNullOrEmpty(sPrice) || sPrice == "0")
                {
                    gridView1.FocusedRowHandle = i;
                    gridView1.SetColumnError(colPrice, string.Format("Bạn chưa nhập giá sản phẩm! ESC để bỏ qua."));
                    return false;
                }
                if (string.IsNullOrEmpty(sPrice1) || sPrice1 == "0")
                {
                    gridView1.FocusedRowHandle = i;
                    gridView1.SetColumnError(colPrice1, string.Format("Bạn chưa nhập giá sản phẩm! ESC để bỏ qua."));
                    return false;
                }
                if (string.IsNullOrEmpty(sPrice2) || sPrice2 == "0")
                {
                    gridView1.FocusedRowHandle = i;
                    gridView1.SetColumnError(colPrice2, string.Format("Bạn chưa nhập giá sản phẩm! ESC để bỏ qua."));
                    return false;
                }
                if (string.IsNullOrEmpty(sPrice3) || sPrice3 == "0")
                {
                    gridView1.FocusedRowHandle = i;
                    gridView1.SetColumnError(colPrice3, string.Format("Bạn chưa nhập giá sản phẩm! ESC để bỏ qua."));
                    return false;
                }
                if (string.IsNullOrEmpty(sQuantity) || sQuantity == "0")
                {
                    gridView1.FocusedRowHandle = i;
                    gridView1.SetColumnError(colQuantity, string.Format("Bạn chưa nhập số lượng sản phẩm! ESC để bỏ qua."));
                    return false;
                }
                //kiểm tra có lớn số lượng chứa trong kho quui định không
                int quantity = Convert.ToInt32(sQuantity == "" ? "0" : sQuantity);
                string maPos = gridView1.GetRowCellValue(i, colPosition) + string.Empty;
                //string maPos = gridView1.GetFocusedRowCellValue(colPosition) + string.Empty;
                position_x_inventory tempX = _positionXPresenter.GetById(maPos);
                if (tempX != null && (tempX.Posx_Quantity_Max - tempX.Posx_Quantity) < quantity)
                {
                    gridView1.SetColumnError(colQuantity, "Số lượng chứa trong không đủ");
                    return false;
                }
            }
            //kiểm tra có lớn số lượng chứa trong kho quui định không
            var query = from p in _inventoryDetailses
                        group p by new { p.Invd_POSITION_X_ID } into Grouped
                        select new inventory_details()
                            {
                                Invd_POSITION_X_ID = Grouped.Key.Invd_POSITION_X_ID,
                                Invd_Quantity = Grouped.Sum(p => p.Invd_Quantity)
                            };
            foreach (var item in query)
            {
                // int quantity = Convert.ToInt32(sQuantity);
                //string maPos = gridView1.GetFocusedRowCellValue(colPosition) + string.Empty;
                position_x_inventory tempX = _positionXPresenter.GetById(item.Invd_POSITION_X_ID);
                if (tempX != null && (tempX.Posx_Quantity_Max - tempX.Posx_Quantity) < item.Invd_Quantity)
                {
                    ClsMsgBox.Loi(string.Format("Ô {0}: Số lượng chứa trong không đủ", tempX.Posx_Code_X));
                    return false;
                }
            }
            if (_inventoryDetailses.Count == 0)
            {
                ClsMsgBox.ThongTin("Vui lòng nhập sản phẩm");
                return false;
            }
            return true;
        }


        #endregion

        

        
























    }
}